/*
 * @Description: Description
 * @Author: LL
 * @LastEditors: LL
 * @Date: 2021-03-26 09:52:26
 * @LastEditTime: 2021-03-27 17:25:45
 */
import Vue from 'vue'
import Router from 'vue-router'
import modules from './modules/index'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'
export const constantRoutes = [
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path(.*)',
        component: () => import('@/views/redirect/index')
      }
    ]
  },
  {
    path: '/', // 首页
    component: () => import('@/views/dashboard/index'),
    name: 'dashboard'
  },
  { // 管理下属
    path: '/management',
    component: () => import('@/views/dashboard/management'),
    name: 'management'
  },
  { // 编制/维护 compile
    path: '/compile',
    component: () => import('@/views/dashboard/compile'),
    name: 'compile'
  },
  { // 点评
    path: '/comment',
    component: () => import('@/views/dashboard/comment'),
    name: 'comment'
  },
  { // changeRecord 变更记录
    path: '/changeRecord',
    component: () => import('@/views/dashboard/changeRecord/index'),
    name: 'changeRecord'
  },
  { // checkSubordinates 查看下属
    path: '/checkSubordinatesview',
    component: () => import('@/views/dashboard/checkSubordinatesview'),
    name: 'checkSubordinatesview'
  },
  // mainTask
  { // mainTask 主任务封装
    path: '/mainTask',
    component: () => import('@/views/dashboard/mainTask'),
    name: 'mainTask'
  },
  { // reviewIndex 审核
    path: '/reviewIndex',
    component: () => import('@/views/dashboard/reviewIndex'),
    name: 'reviewIndex'
  },
  { // viewIndex 查看
    path: '/viewIndex',
    component: () => import('@/views/dashboard/viewIndex'),
    name: 'viewIndex'
  },
  { // viewApproval 查看
    path: '/viewApproval',
    component: () => import('@/views/dashboard/viewApproval'),
    name: 'viewApproval'
  },
  { // subordinates 查看下属
    path: '/subordinates',
    component: () => import('@/views/dashboard/subordinates'),
    name: 'subordinates'
  },
  { // auditView 查看下属
    path: '/auditView',
    component: () => import('@/views/dashboard/auditView'),
    name: 'auditView'
  },
  // quarterIndex
  { // quarterIndex 季度填写
    path: '/quarterIndex',
    component: () => import('@/views/dashboard/quarterIndex'),
    name: 'quarterIndex'
  },
  { // seeQuarterIndex 季度填写提交--查看
    path: '/seeQuarterIndex',
    component: () => import('@/views/dashboard/seeQuarterIndex'),
    name: 'seeQuarterIndex'
  },
  { // auditQuarter 季度--领导审核
    path: '/auditQuarter',
    component: () => import('@/views/dashboard/auditQuarter'),
    name: 'auditQuarter'
  },
  { // auditSeeQuarter 季度--领导审核--反馈之后的查看
    path: '/auditSeeQuarter',
    component: () => import('@/views/dashboard/auditSeeQuarter'),
    name: 'auditSeeQuarter'
  },
  { // 跟踪我的一人一表
    path: '/tracking',
    component: () => import('@/views/dashboard/tracking'),
    name: 'tracking'
  }

]

export const asyncRoutes = [
  ...modules,
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
